package com.cdcas;

public class Book2 implements Comparable<Book2>{
    private String titile;
    private String author;
    private double price;

    public Book2(String titile,String author,double price) {
        this.titile = titile;
        this.author = author;
        this.price = price;
    }

    @Override
    public String toString() {
        return "Book2{" +
                "titile='" + titile + '\'' +
                ", author='" + author + '\'' +
                ", price=" + price +
                '}';
    }

    @Override
    public int compareTo(Book2 o) {
        if (this.price>o.price) {
            return 1;
        } else if (this.price < o.price) {
            return -1;
        } else {
            if (this.titile.compareTo(o.titile) >0) {
                return 1;
            } else if (this.titile.compareTo(o.titile) <0) {
                return -1;
            } else {
                if (this.author.compareTo(o.author)>0) {
                    return  1;
                } else if (this.author.compareTo(o.author)<0) {
                    return -1;
                } else {
                    return 0;
                }
            }
        }
    }
}
